home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / GENetReleaseƒ / GELibHeaders / Rects.h < prev    next >
Text File  |  1994-03-07  |  2KB  |  87 lines

  1. /*
  2.     Rects.h
  3.     
  4.     Rectangle handling routines for Graphic Elements release version 1.0b1
  5.     
  6.     Copyright 1994 by Al Evans. All rights reserved.
  7.     
  8.     3/7/94
  9.     
  10. */
  11.  
  12. #include "List.h"
  13.  
  14. //Entry in a list of rectangles
  15. typedef struct rEntry *RListEntryPtr;
  16.  
  17. typedef struct rEntry {
  18.     RListEntryPtr        nextEntry;
  19.     Rect                thisRect;
  20. } RListEntry;
  21.  
  22. //Coding masks for overlapping rectangles, see CodeRects below
  23. typedef enum {    noOvlp =        0,
  24.                 ovlpTop =         1,
  25.                   ovlpLeft =        1 << 1,
  26.                 ovlpBottom =    1 << 2,
  27.                 ovlpRight =        1 << 3,
  28.                 ovlpTR =        1 << 4,
  29.                 ovlpTL =        1 << 5,
  30.                 ovlpBL =        1 << 6,
  31.                 ovlpBR =        1 << 7,
  32.                 uncoded =        1 << 8
  33.              } RectCode;
  34.  
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38.  
  39.  
  40. //Returns a code as defined above showing how testRect overlaps baseRect
  41. RectCode CodeRect(const Rect* testRect, const Rect* baseRect);
  42.  
  43. /*
  44.     The following function is meant to be called iteratively until it returns
  45.     false. If code is non-zero, it returns rectangles in *src2 and *dst2 which
  46.     represent srcRect and dstRect "wrapped around" totalSource. It alters
  47.     the value of code, to reflect the fact that it has handled one case of 
  48.     "wraparound". If code is noOvlp, it clips srcRect against totalSource,
  49.     clips destRect accordingly, and returns the results in src2 and dst2.
  50. */
  51.  
  52. Boolean SplitRects(RectCode *code, const Rect* totalSource, const Rect* srcRect,
  53.         const Rect* dstRect, Rect* src2, Rect* dst2);
  54.  
  55.  
  56. //Rectangle list functions
  57.  
  58. //Returns new rectangle list
  59. LHeaderPtr InitRectList(short nRects);
  60.  
  61. Boolean InsertRectInList(LHeaderPtr listHead, Rect* theRect);
  62.  
  63. //Removes all rectangles from rectList
  64. void ClearRectList( LHeaderPtr rectList);
  65.  
  66.  
  67. //Fast assembly-language rectangle arithmetic
  68.  
  69. //IFF rects intersect, intersection is returned in rect2
  70. extern Boolean RectsIntersect(const Rect * rect1, Rect * rect2);
  71.  
  72. // rect2 = rect1 U rect2
  73. extern void RectUnion(Rect * rect1, Rect * rect2 );
  74.  
  75. // rect1->top = rect1->left = rect1->bottom = rect1->right = 0
  76. extern void RectZero(Rect * rect1);
  77.  
  78. // true IFF (rect1->top >= rect1->bottom) || (rect1->left >= rect1->right)
  79. extern Boolean RectEmpty(Rect * rect1);
  80.  
  81. // Offsets rect1 by dx, dy
  82. extern void RectOffset(Rect * rect1, long dx, long dy);
  83.  
  84. #ifdef __cplusplus
  85. }
  86. #endif
  87.